package com.itheima.reggie.mapper;

import com.itheima.reggie.entity.Category;
import com.itheima.reggie.entity.Dish;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Service;

import java.util.List;

@Mapper
public interface CategoryMapper {

    //查询数据
    @Select("select * from category order by sort ")
    public List<Category> page ();

    //添加分类
    @Insert("INSERT INTO category VALUES (null , #{type} , #{name} , #{sort} , #{CreateTime} , #{updateTime} , #{createUser} , #{updateUser});")
    void addCategory(Category category);

    //编辑分类
    @Update("UPDATE category SET name = #{name} , sort = #{sort} , update_time = #{updateTime} , update_user = #{updateUser}  WHERE id = #{id};")
    void editCategory(Category category);

    //删除分类
    @Delete("DELETE FROM category WHERE id = #{id};")
    void deleteCategory(Long id);

    //查看所以的分类，根据类型id
    List<Category> findAllByType(Integer type);

}
